#include "core\Roguelike.h"
#include "core\Graphics.h"

GL_Application* GL_Application::create(const char *className)
{
	RoguelikeApp* app=new RoguelikeApp(className);
	return reinterpret_cast<GL_Application*>(app);
}

RoguelikeApp::RoguelikeApp(const char *className) : GL_Application(className)
{
}

bool RoguelikeApp::initialize()
{
  FontManager::getInstance()->setHDC(GetDC(HWND(m_window)));
	m_stateManager = new StateManager();  
  m_stateManager->changeState(Graphics::getInstance(m_stateManager));
  
	resizeDraw(true);
	return true; 
}

void RoguelikeApp::deinitialize()
{
  delete m_stateManager;
}

void RoguelikeApp::update(DWORD milliseconds)
{  
  APP_MSG msg = m_stateManager->update(milliseconds, &m_keys, &m_mouse);
  switch(msg)
  {
  case(MSG_QUIT):
    terminateApplication();
    break;
  case(MSG_TOGGLE_FULLSCREEN):
    toggleFullScreen();
    break;
  }
}

void RoguelikeApp::draw()
{
  m_stateManager->draw();
}